package com.itheima.qingcheng.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 通过用结果类
 * @author ghy
 * @version V1.0
 * @date 2025-01-20 20:37
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    /**
     * 1:成功  0失败
     */
    private Integer code;

    /**
     * 提示消息
     */
    private String message;

    /**
     * 附加数据
     */
    private T data;

    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>();
        result.setCode(1);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> success(){
        Result<T> result = new Result<>();
        result.setCode(1);
        return result;
    }

    public static <T> Result<T> error(T data){
        Result<T> result = new Result<>();
        result.setCode(0);
        result.setData(data);
        return result;
    }


}
